package com.cnebula.uas.sso.model;

import java.io.StringWriter;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "UMPrincipal")
@XmlAccessorType(XmlAccessType.NONE)
public class UMPrincipal {

	/****************
	 * 实体属性部分
	 ****************/
	/**
	 * 用户ID 流水号
	 */
	@XmlAttribute
	String id;

	/**
	 * 用户姓名
	 */
	@XmlAttribute
	String name;

	/**
	 * 用户状态 <item key="0" defaultLang="zh_CN">
	 * <locale value="None(0)" lang="en_US"/>
	 * <locale value="注销(0)" lang="zh_CN"/> </item>
	 * <item key="1" defaultLang="zh_CN">
	 * <locale value="Stopped(1)" lang="en_US"/>
	 * <locale value="停用(1)" lang="zh_CN"/> </item>
	 * <item key="2" defaultLang="zh_CN">
	 * <locale value="Active(2)" lang="en_US"/>
	 * <locale value="启用(2)" lang="zh_CN"/> </item>
	 * <item key="3" defaultLang="zh_CN">
	 * <locale value="Wait for verfying(3)" lang="en_US"/>
	 * <locale value="待审核(3)" lang="zh_CN"/> </item>
	 */
	@XmlAttribute
	int status = 2;
	/**
	 * 帐户ID
	 */
	@XmlAttribute
	String loginId;

	@XmlAttribute
	String localLoginId;

	@XmlAttribute
	boolean checkOrgIp = false;

	@XmlAttribute
	boolean ipUser = false;

	/**
	 * 帐户生效日期
	 */
	@XmlAttribute
	Date validDate = new Date();
	/**
	 * 帐户失效日期
	 */
	@XmlAttribute
	Date invalidDate = new Date(System.currentTimeMillis() + 1000L * 3600 * 24 * 365 * 50);

	// 自然人属性

	/**
	 * 性别
	 */
	@XmlAttribute
	String sex = "m";
	/**
	 * 职务、职称
	 */
	@XmlAttribute
	String position;
	/**
	 * 电子邮箱
	 */
	@XmlAttribute
	String email;
	/**
	 * 电话
	 */
	@XmlAttribute
	String phone;
	// /**
	// * 网络消息传输工具类型：如qq、msn
	// */
	@XmlAttribute
	String msgType = "qq";

	@XmlAttribute
	String msgCode;
	/**
	 * 用户类型，可根据类型确定扩展属性模板 可以是应用系统用户 发证员、读者、管理员
	 */
	int userType = 1;

	/**
	 * 传真号码
	 */
	@XmlAttribute
	String fax;

	/**
	 * 教育程度
	 */
	@XmlAttribute
	String education;

	/**
	 * 用于用户对自己所在单位的描述，除非该用户所在“机构实体中的机构”就是他实际的机构。
	 */
	@XmlAttribute
	String institute;

	/**
	 * 办公地址
	 */
	@XmlAttribute
	String officeAddr;
	/**
	 * 通信地址
	 */
	@XmlAttribute
	String mailAddr;
	/**
	 * 邮政编码
	 */
	@XmlAttribute
	String postalCode;

	/**
	 * 居住地址
	 */
	@XmlAttribute
	String homeAddress;

	/**
	 * 出生日期
	 */
	@XmlAttribute
	Date birthday;

	Map<String, String> extAttributes = new HashMap<String, String>();

	@XmlAttribute
	String otherPropertity1;

	@XmlAttribute
	String otherPropertity2;

	@XmlAttribute
	String otherPropertity3;

	/*
	 * 1：高中， 2：中专， 3：大专， 4：本科， 5：硕士， 6：博士， 7：博士后
	 */
	@XmlAttribute
	int background;
	@XmlAttribute
	boolean directlyUser;
	@XmlAttribute
	String collegeName;
	@XmlAttribute
	String departmentName;
	@XmlAttribute
	String professionalName;
	// String stopReason ;
	@XmlAttribute
	int userGroup;
	int maxConcurrentNumber = -1;

	boolean localRegisted = true;

	// 以下reserved_0到reserved_9为系统保留字段，这些字段仅供UM系统开发人员内部使用
	String reserved_0;
	String reserved_1;
	String reserved_2;
	String reserved_3;
	String reserved_4;
	String reserved_5;
	String reserved_6;
	String reserved_7;
	String reserved_8;
	String reserved_9;

	// 以下depext_0到depext_9
	// 扩展字段，主要面向部署应用实际情况有UMPrincipal没有明确定义的字段，其中depext_0字段用作馆员属性已经启用
	String depext_0 = "0"; // 已经启用
	String depext_1;
	String depext_2;
	String depext_3;
	String depext_4;
	String depext_5;
	String depext_6;
	String depext_7;
	String depext_8;
	String depext_9;

	protected int version;

	BigDecimal totalCashValue = new BigDecimal(0);
	
	Organization orgainzation;
	
	Card card;


	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public int getStatus() {
		return status;
	}


	public void setStatus(int status) {
		this.status = status;
	}


	public String getLoginId() {
		return loginId;
	}


	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}


	public String getLocalLoginId() {
		return localLoginId;
	}


	public void setLocalLoginId(String localLoginId) {
		this.localLoginId = localLoginId;
	}


	public boolean isCheckOrgIp() {
		return checkOrgIp;
	}


	public void setCheckOrgIp(boolean checkOrgIp) {
		this.checkOrgIp = checkOrgIp;
	}


	public boolean isIpUser() {
		return ipUser;
	}


	public void setIpUser(boolean ipUser) {
		this.ipUser = ipUser;
	}


	public Date getValidDate() {
		return validDate;
	}


	public void setValidDate(Date validDate) {
		this.validDate = validDate;
	}


	public Date getInvalidDate() {
		return invalidDate;
	}


	public void setInvalidDate(Date invalidDate) {
		this.invalidDate = invalidDate;
	}


	public String getSex() {
		return sex;
	}


	public void setSex(String sex) {
		this.sex = sex;
	}


	public String getPosition() {
		return position;
	}


	public void setPosition(String position) {
		this.position = position;
	}


	public String getEmail() {
		return email;
	}


	public void setEmail(String email) {
		this.email = email;
	}


	public String getPhone() {
		return phone;
	}


	public void setPhone(String phone) {
		this.phone = phone;
	}


	public String getMsgType() {
		return msgType;
	}


	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}


	public String getMsgCode() {
		return msgCode;
	}


	public void setMsgCode(String msgCode) {
		this.msgCode = msgCode;
	}


	public int getUserType() {
		return userType;
	}


	public void setUserType(int userType) {
		this.userType = userType;
	}


	public String getFax() {
		return fax;
	}


	public void setFax(String fax) {
		this.fax = fax;
	}


	public String getEducation() {
		return education;
	}


	public void setEducation(String education) {
		this.education = education;
	}


	public String getInstitute() {
		return institute;
	}


	public void setInstitute(String institute) {
		this.institute = institute;
	}


	public String getOfficeAddr() {
		return officeAddr;
	}


	public void setOfficeAddr(String officeAddr) {
		this.officeAddr = officeAddr;
	}


	public String getMailAddr() {
		return mailAddr;
	}


	public void setMailAddr(String mailAddr) {
		this.mailAddr = mailAddr;
	}


	public String getPostalCode() {
		return postalCode;
	}


	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}


	public String getHomeAddress() {
		return homeAddress;
	}


	public void setHomeAddress(String homeAddress) {
		this.homeAddress = homeAddress;
	}


	public Date getBirthday() {
		return birthday;
	}


	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}


	public Map<String, String> getExtAttributes() {
		return extAttributes;
	}


	public void setExtAttributes(Map<String, String> extAttributes) {
		this.extAttributes = extAttributes;
	}


	public String getOtherPropertity1() {
		return otherPropertity1;
	}


	public void setOtherPropertity1(String otherPropertity1) {
		this.otherPropertity1 = otherPropertity1;
	}


	public String getOtherPropertity2() {
		return otherPropertity2;
	}


	public void setOtherPropertity2(String otherPropertity2) {
		this.otherPropertity2 = otherPropertity2;
	}


	public String getOtherPropertity3() {
		return otherPropertity3;
	}


	public void setOtherPropertity3(String otherPropertity3) {
		this.otherPropertity3 = otherPropertity3;
	}


	public int getBackground() {
		return background;
	}


	public void setBackground(int background) {
		this.background = background;
	}


	public boolean isDirectlyUser() {
		return directlyUser;
	}


	public void setDirectlyUser(boolean directlyUser) {
		this.directlyUser = directlyUser;
	}


	public String getCollegeName() {
		return collegeName;
	}


	public void setCollegeName(String collegeName) {
		this.collegeName = collegeName;
	}


	public String getDepartmentName() {
		return departmentName;
	}


	public void setDepartmentName(String departmentName) {
		this.departmentName = departmentName;
	}


	public String getProfessionalName() {
		return professionalName;
	}


	public void setProfessionalName(String professionalName) {
		this.professionalName = professionalName;
	}


	public int getUserGroup() {
		return userGroup;
	}


	public void setUserGroup(int userGroup) {
		this.userGroup = userGroup;
	}


	public int getMaxConcurrentNumber() {
		return maxConcurrentNumber;
	}


	public void setMaxConcurrentNumber(int maxConcurrentNumber) {
		this.maxConcurrentNumber = maxConcurrentNumber;
	}


	public boolean isLocalRegisted() {
		return localRegisted;
	}


	public void setLocalRegisted(boolean localRegisted) {
		this.localRegisted = localRegisted;
	}


	public String getReserved_0() {
		return reserved_0;
	}


	public void setReserved_0(String reserved_0) {
		this.reserved_0 = reserved_0;
	}


	public String getReserved_1() {
		return reserved_1;
	}


	public void setReserved_1(String reserved_1) {
		this.reserved_1 = reserved_1;
	}


	public String getReserved_2() {
		return reserved_2;
	}


	public void setReserved_2(String reserved_2) {
		this.reserved_2 = reserved_2;
	}


	public String getReserved_3() {
		return reserved_3;
	}


	public void setReserved_3(String reserved_3) {
		this.reserved_3 = reserved_3;
	}


	public String getReserved_4() {
		return reserved_4;
	}


	public void setReserved_4(String reserved_4) {
		this.reserved_4 = reserved_4;
	}


	public String getReserved_5() {
		return reserved_5;
	}


	public void setReserved_5(String reserved_5) {
		this.reserved_5 = reserved_5;
	}


	public String getReserved_6() {
		return reserved_6;
	}


	public void setReserved_6(String reserved_6) {
		this.reserved_6 = reserved_6;
	}


	public String getReserved_7() {
		return reserved_7;
	}


	public void setReserved_7(String reserved_7) {
		this.reserved_7 = reserved_7;
	}


	public String getReserved_8() {
		return reserved_8;
	}


	public void setReserved_8(String reserved_8) {
		this.reserved_8 = reserved_8;
	}


	public String getReserved_9() {
		return reserved_9;
	}


	public void setReserved_9(String reserved_9) {
		this.reserved_9 = reserved_9;
	}


	public String getDepext_0() {
		return depext_0;
	}


	public void setDepext_0(String depext_0) {
		this.depext_0 = depext_0;
	}


	public String getDepext_1() {
		return depext_1;
	}


	public void setDepext_1(String depext_1) {
		this.depext_1 = depext_1;
	}


	public String getDepext_2() {
		return depext_2;
	}


	public void setDepext_2(String depext_2) {
		this.depext_2 = depext_2;
	}


	public String getDepext_3() {
		return depext_3;
	}


	public void setDepext_3(String depext_3) {
		this.depext_3 = depext_3;
	}


	public String getDepext_4() {
		return depext_4;
	}


	public void setDepext_4(String depext_4) {
		this.depext_4 = depext_4;
	}


	public String getDepext_5() {
		return depext_5;
	}


	public void setDepext_5(String depext_5) {
		this.depext_5 = depext_5;
	}


	public String getDepext_6() {
		return depext_6;
	}


	public void setDepext_6(String depext_6) {
		this.depext_6 = depext_6;
	}


	public String getDepext_7() {
		return depext_7;
	}


	public void setDepext_7(String depext_7) {
		this.depext_7 = depext_7;
	}


	public String getDepext_8() {
		return depext_8;
	}


	public void setDepext_8(String depext_8) {
		this.depext_8 = depext_8;
	}


	public String getDepext_9() {
		return depext_9;
	}


	public void setDepext_9(String depext_9) {
		this.depext_9 = depext_9;
	}


	public int getVersion() {
		return version;
	}


	public void setVersion(int version) {
		this.version = version;
	}


	public BigDecimal getTotalCashValue() {
		return totalCashValue;
	}


	public void setTotalCashValue(BigDecimal totalCashValue) {
		this.totalCashValue = totalCashValue;
	}


	public Organization getOrgainzation() {
		return orgainzation;
	}


	public void setOrgainzation(Organization orgainzation) {
		this.orgainzation = orgainzation;
	}


	public Card getCard() {
		return card;
	}


	public void setCard(Card card) {
		this.card = card;
	}


	public static void main(String[] args) throws JAXBException {
		UMPrincipal um = new UMPrincipal();
		um.setLoginId("zhangsan");
		um.setName("zhangsan");

		JAXBContext jaxbContext = JAXBContext.newInstance(um.getClass());

		Marshaller marshaller = jaxbContext.createMarshaller();
		// Marshaller.JAXB_FRAGMENT:是否省略xml头信息,true省略，false不省略
		marshaller.setProperty(Marshaller.JAXB_FRAGMENT, false);
		// Marshaller.JAXB_FORMATTED_OUTPUT:决定是否在转换成xml时同时进行格式化（即按标签自动换行，否则即是一行的xml）
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
		// Marshaller.JAXB_ENCODING:xml的编码方式
		marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
		StringWriter writer = new StringWriter();
		marshaller.marshal(um, writer);

		System.out.println(writer.toString());

	}

}
